<?php

// Defaults
$Sp_Chr = '	';
// File Data
$f = 1;
$log = '';
$handle = fopen($filename, "x");

for ($y = 1; $y <= $List[0]; $y++) {
if($List[$y]['FraMonDPago']=='BRL'){$List[$y]['FraMonDPago']='L';}
    $log .= $List[$y]['FraFecha'] . $Sp_Chr;
    $log .= ( $CNC + $y) . $Sp_Chr;
    $log .= preg_replace("#[\-\/\.\ \,]#", "", $List[$y]['BnfCedula']) . $Sp_Chr;
    $log .= $List[$y]['BnfNombre'] . $Sp_Chr;
    $log .= $List[$y]['BnfTelefono'] . $Sp_Chr;
    $log .= str_replace('	', '', $List[$y]['BnfDireccion']) . $Sp_Chr;
    $log .= $List[$y]['BnfCiudad'] . $Sp_Chr;
    $log .= $Sp_Chr;
    $log .= $Sp_Chr;
    $log .= $List[$y]['BnfPais'] . $Sp_Chr;
    $log .= str_pad($List[$y]['bp_IdBanco'], 4, "0", STR_PAD_LEFT) . $Sp_Chr;
    $log .= $List[$y]['cb_Sucursal'] . $Sp_Chr;
    $log .= bpcorrconv($List[$y]['cb_Banco'], $List[$y]['CorrNumero'], $List[$y]['cb_Cuenta'], $List[$y]['cb_TipoCuenta'], $List[$y]['cb_Cuenta_prx'], $List[$y]['cb_Cuenta_sux'], $List[$y]['cb_Cuenta_mod']) . $Sp_Chr;
    $log .= $List[$y]['TipoCuenta'] . $Sp_Chr;
    $log .= $List[$y]['CliNombre'] . $Sp_Chr;
    $log .= $List[$y]['CliDNI'] . $Sp_Chr;
    $log .= $Sp_Chr;
    $log .= $List[$y]['CliCiudad'] . $Sp_Chr;
    $log .= $Sp_Chr;
    $log .= $Sp_Chr;
    $log .= 'PORTUGAL' . $Sp_Chr;
    $log .= $List[$y]['FraARecibir'] . $Sp_Chr;
    $log .= $List[$y]['FraMonDPago'] . $Sp_Chr;
    $log .= $List[$y]['bp_Name'] . $Sp_Chr;
    $log .= $List[$y]['FraModo'] . $Sp_Chr;
    $log .= $List[$y]['ORInternal'] . $Sp_Chr;
    $log .= $List[$y]['FraModoPago'] . $Sp_Chr;
    $log .= $List[$y]['ORInternal'] . $Sp_Chr . PHP_EOL;
}
fwrite($handle, $log);
fclose($handle);